<?php
$map = array();//客户端集合
$server = new swoole_websocket_server("192.168.88.108", 9501);
$server->on('open', function (swoole_websocket_server $server, $request) {
    global $map;//客户端集合
    $map[$request->fd] = $request->fd;//首次连上时存起来
});
$server->on('message', function (swoole_websocket_server $server, $frame) {
    global $map;//客户端集合
    $data = $frame->data;
    foreach($map as $fd){
        $server->push($fd , $data);//循环广播
    }
});
$server->on('close', function ($ser, $fd) {
    echo "client {$fd} closed\n";
});
$server->start();